package com.zyc.simpleFactoryMode;

/**
 * 简单工厂模式可以根据输入条件创建指定的实现类
 * 简单工厂返回对象实例
 * @author zyc
 * @create 2022--06--10 11:23
 */
public class OperationFactory {
    public static Operation createOperate(char operate) throws Exception {
        Operation operation = null;
        switch (operate) {
            case '+':
                operation = new OperationAdd();
                break;
            case '-':
                operation = new OperationSub();
                break;
            default:
                throw new Exception("输入的运算符有误");
        }
        return operation;
    }
}
